package com.example.principle.config;

import com.example.principle.model.Server;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class ServerConfig {
    @Bean
    public Server getServer(){
        Server server = new Server();
        server.setId(10);
        return server;
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    public Server getSingleton(){
        Server server = new Server();
        server.setId(1);
        return server;
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Server getPrototype(){
        Server server = new Server();
        server.setId(2);
        return server;
    }

    @Bean
    @RequestScope
    public Server getRequest(){
        Server server = new Server();
        server.setId(3);
        return server;
    }

    @Bean
    @SessionScope
    public Server getSession(){
        Server server = new Server();
        server.setId(4);
        return server;
    }

    @Bean
    @ApplicationScope
    public Server getApplication(){
        Server server = new Server();
        server.setId(5);
        return server;
    }
}
